package com.xc.freeapp.dao.dataSource;

public class DBContextHolder {  
	  
    /** 
     * 线程threadlocal 
     */  
    private static ThreadLocal<String> dataSourceKey = new ThreadLocal<String>();  
  
    public static String DB_TYPE_RW = "dataSource";  
    public static String DB_TYPE_R = "dataSourceR";  
  
    public static void switchDataSourceRW() {
        dataSourceKey.set(DB_TYPE_RW);
    }

    public static void switchDataSourceR() {
        dataSourceKey.set(DB_TYPE_R);
    }

    public static void setDataSourceType(String dataSourceType) {
        dataSourceKey.set(dataSourceType);
    }

    public static String getDataSourceType() {
        return dataSourceKey.get();
    }

    public static void clear() {
        dataSourceKey.remove();
    }
}  